
/*
    分别实现一台车和一部手机的class
*/

interface PublicType {
    name: string,
    brand: string,
    price: number,
    color: string,
    func(): void
}

interface CarType extends PublicType {
    // 速度
    speed: number,
    // 拉货
    lahuo: (arr: string[]) => string
}

interface PhoneType extends PublicType {
    size: string,
    // 抖音
    tiktok: (x: number) => number
}

class Car implements CarType {
    name: string;
    brand: string;
    price: number;
    color: string;
    speed: number;

    constructor(n: string, b: string, p: number, c: string, s: number){
        this.name = n;
        this.brand = b;
        this.color = c;
        this.speed = s;
    }

    func() {
        console.log('开着邻居家的 ' + this.name);
    }

    lahuo(arr: string[]) {
        return '拉了很多的货' + arr.toString()
    }
}

const c1 = new Car('Toyota', '丰田', 59, '灰色', 180);

console.log(c1);
c1.func()
console.log(c1.lahuo(['电冰箱', '空调', '洗衣机']));
;